/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package luft27.comm.mavlink;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;

/**
 *
 * @author amalikov
 */
public class NavControllerOutput implements MessagePayload {
	public float nav_roll;
	public float nav_pitch;
	public float alt_error;
	public float aspd_error;
	public float xtrack_error;
	public short nav_bearing;
	public short target_bearing;
	public short wp_dist;

	@Override
	public byte[] get() {
		ByteBuffer bb = ByteBuffer.allocate(256).order(ByteOrder.LITTLE_ENDIAN);
		bb.putFloat(nav_roll);
		bb.putFloat(nav_pitch);
		bb.putFloat(alt_error);
		bb.putFloat(aspd_error);
		bb.putFloat(xtrack_error);
		bb.putShort(nav_bearing);
		bb.putShort(target_bearing);
		bb.putShort(wp_dist);
		return Arrays.copyOf(bb.array(), bb.position());
	}

	@Override
	public void set(byte[] data) {
		ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
		nav_roll = bb.getFloat();
		nav_pitch = bb.getFloat();
		alt_error = bb.getFloat();
		aspd_error = bb.getFloat();
		xtrack_error = bb.getFloat();
		nav_bearing = bb.getShort();
		target_bearing = bb.getShort();
		wp_dist = bb.getShort();
	}
}